import {useSelector} from "react-redux";
import {ComponentsStateType} from "../redux/componentsReducer";
import {StoreState} from "../redux";

function useGetComponentInfo() {
  const component = useSelector<StoreState>(state => state.components.present) as ComponentsStateType
  const {selectedId = '', componentList = [], copyComponent} = component
  const selectedComponent = componentList.find(c => c.fe_id === selectedId)
  return {componentList, selectedId, selectedComponent, copyComponent}
}

export default useGetComponentInfo
